Table of Contents
The console application is called udefrag.exe. It is placed in system32 directory by the installer. Therefore you can call it from the command line or run box.
Console Application after a successful analyze run.Command promptMicrosoft Windows XP [5.1.2600] (C) Microsoft Corporation, 1985-2001. C:\>udefrag -a c:UltraDefrag v2.1.2console interface Copyright (c) Dmitri Arkhangelski, 2007,2008. Volume information: Volume size = 3.92 Gb Free space = 917.56 Mb Total number of files = 14688 Number of fragmented files = 126 Fragments per file = 1.21C:\>_
The command line version takes a drive letter and one of the following switches:
-a | analyze the drive specified on the command line |
-o | optimize file space by moving all files to the begining of the drive |
-l | list volumes available for defragmentation except removable |
-la | list all volumes available for defragmentation |
-b | use default color scheme (usually black/white) |
-? | displays the usage message (-h has the same effect) |
Specifying just the drive letter will cause UltraDefrag to defragment the drive. When the operation finishes or you stop the program with a Ctrl+C, the program will display the results to the console. If you abort the operation with Ctrl+C or close the shell window, UltraDefrag will exit safely without destroying any data.
To get list of available volumes type udefrag -l. Each line of output contains volume letter, type of file system, total size and percent of free space. Here is an example:
Command promptMicrosoft Windows XP [5.1.2600] (C) Microsoft Corporation, 1985-2001. C:\>udefrag -lUltraDefrag v2.1.2 console interface Copyright (c) Dmitri Arkhangelski, 2007,2008.Volumes available for defragmentation: C: NTFS 3.92 Gb 6 % D: NTFS 9.42 Gb 3 % E: FAT32 59.30 Gb 5 %C:\>_
To set defragmenter options you should use the Environment Variables. To set each of them you can simply type in command line set VarName=Value where VarName is a name of the environment variable and Value is a string to be assigned to the specified variable. The good practice is to store such commands in a batch script before udefrag.exe calls. That will save a lot of your time. This practice will be discussed below. Here is a list of defragmentation related environment variables with a full explaination:
UD_IN_FILTER |
List of files to be included in defragmentation process. File names must be separated by
semicolon. Most useful example is: set UD_IN_FILTER=My Documents.
After this assignment the defragger will process My Documents
directory contents only. The default value is an empty string that means: all files will be included. |
UD_EX_FILTER |
List of files to be excluded from defragmentation process.
File names must be separated by semicolon. Most useful example is:
set UD_EX_FILTER=system volume information;temp;recycler.
After this assignment many temporary files will be excluded from the
defragmentation process. The default value is an empty string. It means: no files will be excluded. |
UD_SIZELIMIT |
Ignore files larger than specified value. You can either specify size in bytes
or use the following suffixes: Kb, Mb, Gb, Tb, Pb, Eb. P.a., use set UD_SIZELIMIT=10Mb to exclude all files greater than 10 megabytes. The default value is zero. It means: there is no size limit. |
UD_REFRESH_INTERVAL |
Specify the progress indicator refresh interval in milliseconds.
The default value is 500. |
UD_DISABLE_REPORTS |
Set this parameter to 1 (one) to disable reports generation.
The default value is 0. |
UD_DBGPRINT_LEVEL |
This parameter can be in one of three states. Set
UD_DBGPRINT_LEVEL=NORMAL to view useful messages about
the analyse or defrag progress. Select DETAILED to create
a bug report to send to the author when an error is encountered. Select
PARANOID in extraordinary cases. Of course, you need have DbgView
program or DbgPrint Logger installed to view logs.
The default value is NORMAL. |
Notes about filter:
The console application is also used as a context menu handler. When you right click drive/folder/file icon in Explorer you can select
menu item to defragment the selected object.To stop the defragmentation press Ctrl+C keys 4 times or close the console application window.
The best practice is to use the console application in batch scripts. You can define all program's options there and defragment multiple volumes in series by typing a single command. Here is the complete example. To try them store the code into ud-example.cmd file and click it's icon.
@echo off
set UD_EX_FILTER=system volume information;temp;recycler
set UD_SIZELIMIT=50Mb
udefrag c: > c:\ud.log
set UD_IN_FILTER=My Documents
udefrag d: >> c:\ud.log
set UD_IN_FILTER=
udefrag e: >> c:\ud.log
The command set UD_IN_FILTER= destroys the specified variable. The appropriate option will have the default value after this command.
Batch files are powerful enough, try to insert commands to play sounds after each defragmentation. If you doubt that your volumes are in good state then add chkdsk command too. Also you can use shutdown -s -t 00 command to halt your computer after the defragmentation job.